import java.util.*;

public class NumberOfDecomposition {
    public static void main(String[] args) {
        int count = 0;
        Set<String> set = new HashSet<>();
        for (int i = 1; i < 2019; i++) {
            for (int j = i + 1; j < 2019; j++) {
                for (int k = j + 1; k < 2019; k++) {
                    if (i + j + k == 2019) {
                        if (isNoContains4Or2(i) && isNoContains4Or2(j) && isNoContains4Or2(k)) {
                            if (set.isEmpty()) {
                                count ++;
                                List<String> list = allArrange(i, j, k);
                                set.addAll(list);
                                continue;
                            }
                            if (!set.contains("" + i + j + k)) {
                                count++;
                                List<String> list = allArrange(i, j, k);
                                set.addAll(list);
                            }
                        }
                    }
                }
            }
        }
        System.out.println(count);
    }

    public static List<String> allArrange(int i, int j, int k) {
        List<String> ret = new LinkedList<>();
        int[] nums = new int[] {i, j, k};
        arrange(ret, nums, 0, "");
        return ret;
    }

    private static void arrange(List<String> ret, int[] nums, int depth, String s) {
        if (depth >= 3) {
            ret.add(s);
            return;
        }
        for (int i = depth; i < nums.length; i++) {
            arrange(ret, nums, depth + 1, s + i);
        }
    }

    public static boolean isNoContains4Or2(int num) {
        while (num > 0) {
            int last = num % 10;
            if (last == 2 || last == 4) {
                return false;
            }
            num = num / 10;
        }
        return true;
    }
}
